/*
 * Copyright 2017 JessYan
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.yiqi.news.mvp.model.api.service

import com.yiqi.news.entity.*
import io.reactivex.Observable
import okhttp3.MultipartBody

import retrofit2.Retrofit
import retrofit2.http.*

/**
 * ================================================
 * 展示 [Retrofit.create] 中需要传入的 ApiService 的使用方式
 * 存放关于用户的一些 API
 *
 *
 * Created by JessYan on 08/05/2016 12:05
 * [Contact me](mailto:jess.yan.effort@gmail.com)
 * [Follow me](https://github.com/JessYanCoding)
 * ================================================
 */
interface UserService {


    /**
     * 发送短信验证码
     * */
    @GET("api/sms")
    fun sendCode(@Query("phone") phone: String): Observable<BaseResponse<User>>


    /**
     * 登录
     * */
    @POST("api/login")

    fun login(@Query("mobile") mobile: String, @Query("code") code: String): Observable<BaseResponse<User>>

    /**
     * 绑定邀请码
     * */
    @POST("api/register")

    fun bind(@Body map: HashMap<String, Any?>): Observable<BaseResponse<User>>

    /**
     * 获取用户信息
     * */
    @POST("api/user/infoById")
    fun userInfo(): Observable<BaseResponse<User>>

    /**
     * 用户提现记录信息
     */
    @FormUrlEncoded
    @POST("api/gold/userCashRecord")
    fun cashRecord(@Field("page") page: Int): Observable<BaseResponse<Page<CashRecord>>>

    /**
     * 用户金币信息
     */
    @POST("api/gold/userGoldInfo")
    fun goldInfo(): Observable<BaseResponse<GoldInfo>>

    /**
     * 金币流水记录
     */
    @FormUrlEncoded
    @POST("api/gold/goldChangRecord")
    fun goldRecord(@Field("page") page: Int): Observable<BaseResponse<Page<GoldRecord>>>

    /**
     * 收藏
     */
    @FormUrlEncoded
    @POST("api/user/userMaterials")
    fun collection(@Field("page") page: Int): Observable<BaseResponse<Page<News>>>

    /**
     * 添加银行卡
     * */

    @POST("api/user/addBankCard")
    fun insertCard(@Body map: HashMap<String, Any?>): Observable<BaseResponse<User>>


    /**
     * 添加金币
     * */
    @FormUrlEncoded
    @POST("api/material/readNews")
    fun readNews(@Query("readTime") readTime: Int, @Field("status") status: Boolean): Observable<BaseResponse<User>>

    /**
     * 更新阅读时间
     */
    @POST("api/user/readtoday")
    fun updateReadTime(@Query("time") readTime: Long): Observable<BaseResponse<User>>


    /**
     *
     * */
    @POST("api/user/listBankCard")
    fun listBankCard(): Observable<BaseResponse<List<BankCardVO>>>

    /**
     *
     * */
    @GET("api/bank/listBank")
    fun listBank(): Observable<BaseResponse<List<BankTypeVO>>>

    /**
     *
     * */
    @POST("api/user/updateUser")
    fun updateUser(@Body map: HashMap<String, Any?>): Observable<BaseResponse<User>>


    /**
     * 删除银行卡
     * */
    @POST("api/user/deleteBankCard")
    fun deleteBankCard(@Body map: HashMap<String, Any?>): Observable<BaseResponse<User>>


    /**
     * 删除银行卡
     * */
    @POST("api/user/addCashDrawsRecord")
    fun addCashDrawsRecord(@Body map: HashMap<String, Any?>): Observable<BaseResponse<User>>


    /**
     * 上传图片
     */

    @Multipart
    @POST("api/user/upload")
    fun uploadFile1(@Part imageUrl: MultipartBody.Part): Observable<BaseResponse<User>>

    /**
     * 在线获取金币
     */
    @POST("api/user/online")
    fun onLine(): Observable<BaseResponse<Any>>

    fun uploadFile(@Part imageUrl: MultipartBody.Part): Observable<BaseResponse<User>>


    /**
     * 删除银行卡
     * */
    @GET("api/user/sysInfo")
    fun sysInfo(): Observable<BaseResponse<AgreementVO>>
}